/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package view.main;
import model.utility.ImageUtility;
import java.awt.Image;
import java.awt.Graphics2D;
import javax.swing.Timer;
import model.game.InformationLayer;
import java.awt.event.*;
import javax.swing.JPanel;


/**
 *
 * @author Satrio Dewantono
 */
public class SpeechBubbleManager implements ActionListener{
  private boolean havemessage = false;
  private Image image1;
  private Image image2;
  private int x,y,x2,y2;
  private static int playeroffsetx = 175;
  private static int playeroffsety = 100;
  private Timer timer;
  private boolean timedmessage;
  private boolean toolbubble;
  private InformationLayer il_;

  public SpeechBubbleManager(InformationLayer il){
    il_ = il;
  }

  public void stopMessage(){
    havemessage = false;
    toolbubble = false;
  }

  public void actionPerformed(ActionEvent e){
    if(timedmessage){
      havemessage = false;
      timedmessage = false;
      timer.stop();
    }
  }

  public void showSelectedItem(){
    x = playeroffsetx - 35;
    y = playeroffsety - 30;
    havemessage = true;
    timedmessage = true;
    toolbubble = true;
    image1 = ImageUtility.loadImage("resources/pictures/speechbubbles/toolbubble.png");
    image2 = null;
    timer = new Timer(5000,this);
    timer.start();
  }

  public void showHelpPrompt(){
    x = playeroffsetx - 35;
    y = playeroffsety - 30;
    havemessage = true;
    timedmessage = true;
    toolbubble = true;
    image1 = ImageUtility.loadImage("resources/pictures/speechbubbles/toolbubble.png");
    image2 = null;
    timer = new Timer(5000,this);
    timer.start();
  }

  public void teleportPossible(){
    x = playeroffsetx + 40;
    y = playeroffsety - 60;
    havemessage = true;
    image1 = ImageUtility.loadImage("resources/pictures/speechbubbles/teleport.png");
    image2 = null;
  }

  public boolean doIHaveAmessage(){
    return havemessage;
  }

  public boolean isTimedMessage(){
    return timedmessage;
  }

  public boolean isShowingToolBubble(){
    return toolbubble;
  }

  public Image getImage(){
    return image1;
  }

  public Image getImage2(){
    return image2;
  }

  public int getX(){
    return x;
  }

  public int getY(){
    return y;
  }

  public int getX2(){
    return x2;
  }

  public int getY2(){
    return y2;
  }

  public void buyMode(Image itemimg){
    x = playeroffsetx + 40;
    y = playeroffsety - 90;
    havemessage = true;
    timedmessage = false;
    x2 = x+20;
    y2 = y+25;
    image1 = ImageUtility.loadImage("resources/pictures/speechbubbles/buy.png");
    image2 = itemimg;
  }

  public void exitBuyMode(){
    havemessage = false;
    image2 = null;
  }

  public void hireMode(Image spriteimg){
    x = playeroffsetx - 130;
    y = playeroffsety - 90;
    havemessage = true;
    timedmessage = false;
    x2 = x+20;
    y2 = y+25;
    image1 = ImageUtility.loadImage("resources/pictures/speechbubbles/hire.png");
    image2 = spriteimg;
  }

  public void exitHireMode(){
    havemessage = false;
    image2 = null;
  }
}
